package com.jiukuaidao.zhulin.module.order.presenter;

import android.widget.Toast;

import com.jiukuaidao.library.Config;
import com.jiukuaidao.library.net.MyRetroCallBack;
import com.jiukuaidao.library.util.ToastUtil;
import com.jiukuaidao.zhulin.api.ApiOrderComplaint;
import com.jiukuaidao.zhulin.data.TasksRepository;
import com.jiukuaidao.zhulin.module.BasePresenter;
import com.jiukuaidao.zhulin.module.order.contract.ComplaintContract;

/**
 * Author : BinarySatan
 * Date : 2016/6/6
 * Description :
 */
public class ComplaintPresenter extends BasePresenter<ComplaintContract.View, TasksRepository> implements ComplaintContract.Presenter {
    public ComplaintPresenter(TasksRepository repository, ComplaintContract.View view) {
        super(repository, view);
    }

    @Override
    public void start() {

    }

    @Override
    public void submitComplaint() {
        mRepository.loadData(new ApiOrderComplaint(mView.getOrderId(), mView.getComplaintContent(), new MyRetroCallBack<Object>() {
            @Override
            public void onSuccess(Object result, String errorCode, String msg) {
                //TODO 投诉成功弹窗
                mView.complaintSuc();
            }

            @Override
            public void onFail(Object result, String errorCode, String msg) {
                ToastUtil.show(msg, Toast.LENGTH_SHORT);
            }

            @Override
            public void onError(Throwable t, int resCode, String msg) {
                if (Config.Debug) {
                    ToastUtil.show("errorCode  :" + resCode + "\n errorMsg :" + msg, Toast.LENGTH_SHORT);
                }
            }
        }));

    }
}
